Template Literals 與 Destructuring


Posted by cmtilo on 2021-04-30

再也不需要字串拼接:Template Literals

、、 可以放多行字串

例1

var str =、
hey
hi
、

例2

console.log(、hello, ${name.toUpperCase} now is ${new Date( )}、)

聽起來很酷的 Destructuring:解構

例1

const arr = [1, 2, 3, 4]
var [first, second, third, fourth] = arr

例2

const obj = {
 name : 'nick'
 age : 30
 address : 'taiwan'
}
var {name, age, address} = obj

例3

function test({a, b}) {
 console.log(a)
}
test({
 a : 1,
 b : 2
})

#template literals #destructuring







Related Posts

『Android』ADB Debug by wifi 用Wifi連線來Debug

『Android』ADB Debug by wifi 用Wifi連線來Debug

6. 頻率響應

6. 頻率響應

W9_[ BE101 ] PHP 與 MySQL 實作練習 + w9  直播檢討

W9_[ BE101 ] PHP 與 MySQL 實作練習 + w9 直播檢討


Comments